This example roughly follows the code given in the “Forecasting Exports Chulwalar_0.8a.R” file found in the Chulwalar Case Study zip file.

Set Up

library(fpp) # for time series forecasting and analysis
## Loading required package: forecast
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: timeDate
## This is forecast 7.1
## Loading required package: fma
## Loading required package: tseries
## Loading required package: expsmooth
## Loading required package: lmtest
library(forecast) # for some other forecasting models
## The working directory will need changing depending on the computer and file system!!
# setwd("./Dropbox/2016 Summer Courses/MSDS 6306/Unit 10/ChulwalarCase") # data files are here.

Import the data

# Not for final draft of case study.
ImportedAsIsData <- read.csv(file="ImportedAsIsDataChulwalar.csv", header = F, sep=";", fill = T) 
ImportedPlanData <- read.csv(file="ImportedPlanDataChulwalar.csv", header = F, sep=";", fill = T) 
ImportedIndicators <- read.csv(file="ImportedIndicatorsChulwalar.csv", header = F, sep=";", fill = T)
str(ImportedAsIsData)
## 'data.frame':    98 obs. of  8 variables:
##  $ V1: Factor w/ 22 levels "","Apr","Aug",..: 19 9 8 13 2 14 11 10 3 18 ...
##  $ V2: int  2008 2313221 1950131 2346635 2039787 1756964 1458302 1679637 1639670 2882886 ...
##  $ V3: int  2009 2610573 2371327 2743786 2125308 1850073 1836222 1797311 1851968 3271171 ...
##  $ V4: int  2010 2760688 2918333 3227041 1613888 2550157 2317645 1474144 2148521 3898571 ...
##  $ V5: int  2011 3112861 2926663 3294784 2577079 2774068 2378227 2222900 2991787 4151531 ...
##  $ V6: int  2012 3093088 3679308 3433364 2714899 3011767 2726028 2483834 3055655 4200796 ...
##  $ V7: int  2013 4119526 3535744 3560974 3760065 2959933 2787898 2828744 3084113 5107775 ...
##  $ V8: int  2014 4308161 4155378 3924332 3659121 3898758 3313891 3595106 3502426 5619059 ...
str(ImportedPlanData)
## 'data.frame':    97 obs. of  8 variables:
##  $ V1: Factor w/ 20 levels "","Apr","Aug",..: 19 7 6 11 2 12 9 8 3 15 ...
##  $ V2: int  2008 2243103 2162705 2720911 2011182 1877757 1819924 1682196 1893171 3325711 ...
##  $ V3: int  2009 2547980 2247049 2731156 2020158 2098038 1927995 1783692 1907705 3124040 ...
##  $ V4: int  2010 2965885 2751170 2906493 2383358 2246893 1992851 2023434 2244997 3257717 ...
##  $ V5: int  2011 3113110 2883766 2957893 2601648 2370949 2339881 2105328 2341623 4086297 ...
##  $ V6: int  2012 3895396 3588151 3787240 3036434 2907891 2707822 2619486 3784557 4987460 ...
##  $ V7: int  2013 3580325 3863212 3606083 3213575 3139128 2998610 2785453 3083654 5143757 ...
##  $ V8: int  2014 4474000 4185565 4278119 3985542 3605973 3515173 3269444 3656112 5637391 ...
str(ImportedIndicators)
## 'data.frame':    195 obs. of  8 variables:
##  $ V1: Factor w/ 28 levels "","Apr","Aug",..: 7 16 12 20 2 19 18 17 3 26 ...
##  $ V2: num  2008 97.4 97.8 98.3 98.1 ...
##  $ V3: num  2009 98.3 98.9 98.7 98.8 ...
##  $ V4: num  2010 99 99.4 99.9 100 ...
##  $ V5: num  2011 101 101 102 102 ...
##  $ V6: num  2012 103 104 104 104 ...
##  $ V7: num  2013 104 105 106 105 ...
##  $ V8: num  2014 NA NA NA NA ...

Transform data into time series

In order to be able to work with the partial data sets later, these need to be split into individual vectors and converted into times series.

## I would not have this code in the final draft of the case study. These code need to be in an appendix, even if they are put into a makefile.
TotalAsIsVector <- c(ImportedAsIsData [2:13,2],ImportedAsIsData [2:13,3],ImportedAsIsData [2:13,4],ImportedAsIsData [2:13,5],ImportedAsIsData [2:13,6],ImportedAsIsData [2:13,7])
EfakAsIsVector <- c(ImportedAsIsData [16:27,2],ImportedAsIsData [16:27,3],ImportedAsIsData [16:27,4],ImportedAsIsData [16:27,5],ImportedAsIsData [16:27,6],ImportedAsIsData [16:27,7])
WugeAsIsVector <- c(ImportedAsIsData [30:41,2],ImportedAsIsData [30:41,3],ImportedAsIsData [30:41,4],ImportedAsIsData [30:41,5],ImportedAsIsData [30:41,6],ImportedAsIsData [30:41,7])
TotalEtelAsIsVector <- c(ImportedAsIsData [44:55,2],ImportedAsIsData [44:55,3],ImportedAsIsData [44:55,4],ImportedAsIsData [44:55,5],ImportedAsIsData [44:55,6],ImportedAsIsData [44:55,7])
BlueEtelAsIsVector <- c(ImportedAsIsData [58:69,2],ImportedAsIsData [58:69,3],ImportedAsIsData [58:69,4],ImportedAsIsData [58:69,5],ImportedAsIsData [58:69,6],ImportedAsIsData [58:69,7])
RedEtelAsIsVector <- c(ImportedAsIsData [72:83,2],ImportedAsIsData [72:83,3],ImportedAsIsData [72:83,4],ImportedAsIsData [72:83,5],ImportedAsIsData [72:83,6],ImportedAsIsData [72:83,7])
YearAsIsVector <- c(ImportedAsIsData [86,2],ImportedAsIsData [86,3],ImportedAsIsData [86,4],ImportedAsIsData [86,5],ImportedAsIsData [86,6],ImportedAsIsData [86,7])
TotalAsIsVector_2014 <- c(ImportedAsIsData[2:13,8])

PlanVector <- c(ImportedPlanData[2:13,2],ImportedPlanData[2:13,3],ImportedPlanData[2:13,4],ImportedPlanData[2:13,5],ImportedPlanData[2:13,6],ImportedPlanData[2:13,7])
EfakPlanVector <- c(ImportedPlanData[16:27,2],ImportedPlanData[16:27,3],ImportedPlanData[16:27,4],ImportedPlanData[16:27,5],ImportedPlanData[16:27,6],ImportedPlanData[16:27,7])
WugePlanVector <- c(ImportedPlanData[30:41,2],ImportedPlanData[30:41,3],ImportedPlanData[30:41,4],ImportedPlanData[30:41,5],ImportedPlanData[30:41,6],ImportedPlanData[30:41,7])
TotalEtelPlanVector <- c(ImportedPlanData[44:55,2],ImportedPlanData[44:55,3],ImportedPlanData[44:55,4],ImportedPlanData[44:55,5],ImportedPlanData[44:55,6],ImportedPlanData[44:55,7])
BlueEtelPlanVector <- c(ImportedPlanData[58:69,2],ImportedPlanData[58:69,3],ImportedPlanData[58:69,4],ImportedPlanData[58:69,5],ImportedPlanData[58:69,6],ImportedPlanData[58:69,7])
RedEtelPlanVector <- c(ImportedPlanData[72:83,2],ImportedPlanData[72:83,3],ImportedPlanData[72:83,4],ImportedPlanData[72:83,5],ImportedPlanData[72:83,6],ImportedPlanData[72:83,7])
YearPlanVector <- c(ImportedPlanData[86,2],ImportedPlanData[86,3],ImportedPlanData[86,4],ImportedPlanData[86,5],ImportedPlanData[86,6],ImportedPlanData[86,7])
PlanVector_2014 <- c(ImportedPlanData[2:13,8])

# The data is saved as a vector and needs to be converted into a time series
TotalAsIs<- ts(TotalAsIsVector , start=c(2008,1), end=c(2013,12), frequency=12)
EfakAsIs <- ts(EfakAsIsVector , start=c(2008,1), end=c(2013,12), frequency=12)
WugeAsIs <- ts(WugeAsIsVector, start=c(2008,1), end=c(2013,12), frequency=12)
TotalEtelAsIs<- ts(TotalEtelAsIsVector, start=c(2008,1), end=c(2013,12), frequency=12)
BlueEtelAsIs <- ts(BlueEtelAsIsVector, start=c(2008,1), end=c(2013,12), frequency=12)
RedEtelAsIs <- ts(RedEtelAsIsVector, start=c(2008,1), end=c(2013,12), frequency=12)
YearAsIs <- ts(YearAsIsVector, start=c(2008,1), end=c(2013,12), frequency=12)
TotalAsIs_2014 <- ts(TotalAsIsVector_2014, start=c(2014,1), end=c(2014,12), frequency=12)

TotalPlan <- ts(PlanVector , start=c(2008,1), end=c(2013,12), frequency=12)
EfakPlan <- ts(EfakPlanVector, start=c(2008,1), end=c(2013,12), frequency=12)
WugePlan <- ts(WugePlanVector, start=c(2008,1), end=c(2013,12), frequency=12)
TotalEtelPlan <- ts(TotalEtelPlanVector, start=c(2008,1), end=c(2013,12), frequency=12)
BlueEtelPlan <- ts(BlueEtelPlanVector, start=c(2008,1), end=c(2013,12), frequency=12)
RedEtelPlan <- ts(RedEtelPlanVector, start=c(2008,1), end=c(2013,12), frequency=12)
YearPlan <- ts(YearPlanVector, start=c(2008,1), end=c(2013,12), frequency=12)
TotalPlan_2014 <- ts(PlanVector_2014, start=c(2014,1), end=c(2014,12), frequency=12)

# Call up the time series to check everything has worked.

str(TotalAsIs)
##  Time-Series [1:72] from 2008 to 2014: 2313221 1950131 2346635 2039787 1756964 1458302 1679637 1639670 2882886 2959716 ...
str(EfakAsIs)
##  Time-Series [1:72] from 2008 to 2014: 416589 472565 466539 370774 457741 384817 464502 389013 508370 495598 ...
str(WugeAsIs)
##  Time-Series [1:72] from 2008 to 2014: 414571 344579 429907 379606 305697 314582 346800 323618 578252 510031 ...
str(TotalEtelAsIs)
##  Time-Series [1:72] from 2008 to 2014: 1279668 1053325 1367520 1090725 873568 644479 772658 806741 1715265 1795751 ...
str(BlueEtelAsIs)
##  Time-Series [1:72] from 2008 to 2014: 425892 316631 353512 278711 212940 187849 206285 195810 448733 403327 ...
str(RedEtelAsIs)
##  Time-Series [1:72] from 2008 to 2014: 853776 736694 1014008 812014 660628 456630 566373 610931 1266532 1392424 ...
str(YearAsIs)
##  Time-Series [1:72] from 2008 to 2014: 26280011 29609916 32726772 37215503 40629676 45408410 26280011 29609916 32726772 37215503 ...
str(TotalAsIs_2014)
##  Time-Series [1:12] from 2014 to 2015: 4308161 4155378 3924332 3659121 3898758 3313891 3595106 3502426 5619059 5274287 ...
str(TotalPlan)
##  Time-Series [1:72] from 2008 to 2014: 2243103 2162705 2720911 2011182 1877757 1819924 1682196 1893171 3325711 2662148 ...
str(EfakPlan)
##  Time-Series [1:72] from 2008 to 2014: 492421 444995 665274 444369 487668 445242 443318 501222 546249 553286 ...
str(WugePlan) 
##  Time-Series [1:72] from 2008 to 2014: 424190 388688 457796 363828 364246 358439 321255 370153 645618 470648 ...
str(TotalEtelPlan)
##  Time-Series [1:72] from 2008 to 2014: 1263613 1231125 1489621 1051346 933392 932047 855520 923070 2080877 1575579 ...
str(BlueEtelPlan)
##  Time-Series [1:72] from 2008 to 2014: 449227 373663 415732 331337 290942 287603 245390 284540 554127 467772 ...
str(RedEtelPlan)
##  Time-Series [1:72] from 2008 to 2014: 814386 857462 1073889 720009 642450 644444 610130 638530 1526750 1107807 ...
str(YearPlan)
##  Time-Series [1:72] from 2008 to 2014: 27883407 29387100 32780247 35224132 43947063 44152007 27883407 29387100 32780247 35224132 ...
str(TotalPlan_2014)
##  Time-Series [1:12] from 2014 to 2015: 4474000 4185565 4278119 3985542 3605973 3515173 3269444 3656112 5637391 5157781 ...

Basic data analysis

Correlation between As Is and Plan Data

Test the correlation between As Is and Plan data in order to test how exact the planning is. Correlation is a measure of linear relationship between two variables.

cor(TotalAsIs, TotalPlan )
## [1] 0.9183402
cor(EfakAsIs , EfakPlan)
## [1] 0.9055081
cor(WugeAsIs, WugePlan)
## [1] 0.8788474
cor(TotalEtelAsIs, TotalEtelPlan)
## [1] 0.9159505
cor(BlueEtelAsIs , BlueEtelPlan)
## [1] 0.8044146
cor(RedEtelAsIs , RedEtelPlan)
## [1] 0.9106702
cor(YearAsIs, YearPlan)
## [1] 0.9627401

The results show a very high planning accuracy.

TotalAsIs_lm <- lm(TotalAsIs ~ TotalPlan , data = TotalAsIs)
summary(TotalAsIs_lm)
## 
## Call:
## lm(formula = TotalAsIs ~ TotalPlan, data = TotalAsIs)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -770214 -196776   26017  182579  672705 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 8.959e+04  1.521e+05   0.589    0.558    
## TotalPlan   9.627e-01  4.959e-02  19.413   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 332600 on 70 degrees of freedom
## Multiple R-squared:  0.8433, Adjusted R-squared:  0.8411 
## F-statistic: 376.9 on 1 and 70 DF,  p-value: < 2.2e-16
TotalAsIs_tslm <- tslm(TotalAsIs ~ TotalPlan )
summary(TotalAsIs_tslm)
## 
## Call:
## tslm(formula = TotalAsIs ~ TotalPlan)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -770214 -196776   26017  182579  672705 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 8.959e+04  1.521e+05   0.589    0.558    
## TotalPlan   9.627e-01  4.959e-02  19.413   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 332600 on 70 degrees of freedom
## Multiple R-squared:  0.8433, Adjusted R-squared:  0.8411 
## F-statistic: 376.9 on 1 and 70 DF,  p-value: < 2.2e-16

Use STL function for decomposition

The time series can be analysed using the stl function in order to seperate the trend, seasonality and remainder (remaining coincidential) components from one another.

TotalAsIs_stl <- stl(TotalAsIs, s.window=5)
EfakAsIs_stl <- stl(EfakAsIs , s.window=5)
WugeAsIs_stl <- stl(WugeAsIs, s.window=5)
TotalEtelAsIs_stl <- stl(TotalEtelAsIs, s.window=5)
BlueEtelAsIs_stl <- stl(BlueEtelAsIs , s.window=5)
RedEtelAsIs_stl <- stl(RedEtelAsIs , s.window=5)

Thus the individual time series can be shown graphically and tabularly. The trend of the total exports is almost linear. A relatively uniform seaonality can be seen.

par(mfrow=c(3,2))
plot(TotalAsIs_stl, col="black", main="TotalAsIs_stl")

plot(EfakAsIs_stl, col="black", main="EfakAsIs_stl")

plot(WugeAsIs_stl, col="black", main="WugeAsIs_stl")

plot(TotalEtelAsIs_stl, col="black", main="TotalEtelAsIs_stl")

plot(BlueEtelAsIs_stl, col="black", main="BlueEtelAsIs_stl")

plot(RedEtelAsIs_stl, col="black", main="RedEtelAsIs_stl")

It is interesting to note that the almost linear trend is not seen in the individual segments. The individual trends run partially in opposite directions in the middle of the time scale, which causes the linear trend in the total As Is data.

par(mfrow=c(3,2))
plot(TotalAsIs_stl$time.series[,"trend"], col="black")
plot(EfakAsIs_stl$time.series[,"trend"], col="red")
plot(WugeAsIs_stl$time.series[,"trend"], col="blue")
plot(TotalEtelAsIs_stl$time.series[,"trend"], col="green")
plot(BlueEtelAsIs_stl$time.series[,"trend"], col="orange")
plot(RedEtelAsIs_stl$time.series[,"trend"], col="purple")

Modify seasonal component to a monthly base

The modification of the seasonlity component can also be changed into a monthly view. It only makes sense to do this if the seasonality componant as the trend looks almost identical and the remainder is then randomly spread.

monthplot(TotalAsIs_stl$time.series[,"seasonal"], main="", ylab="Seasonal")

monthplot(EfakAsIs_stl$time.series[,"seasonal"], main="", ylab="Seasonal")

monthplot(WugeAsIs_stl$time.series[,"seasonal"], main="", ylab="Seasonal")

monthplot(TotalEtelAsIs_stl$time.series[,"seasonal"], main="", ylab="Seasonal")

monthplot(BlueEtelAsIs_stl$time.series[,"seasonal"], main="", ylab="Seasonal")

monthplot(RedEtelAsIs_stl$time.series[,"seasonal"], main="", ylab="Seasonal")

Correlation with external indicators

The indicators are as follows:

  • Monthly Change in Export Price Index (CEPI)
  • Monthly Satisfaction Index (SI) government based data
  • Average monthly temperatures in Chulwalar
  • Monthly births in Chulwalar
  • Monthly Satisfaction Index (SI) external index
  • Yearly Exports from Urbano
  • Yearly number of Globalisation Party members in Chulwalar
  • Monthly Average Export Price Index for Chulwalar
  • Monthly Producer Price Index (PPI) for Etel in Chulwalar
  • National Holidays
  • Chulwalar Index (Total value of all companies in Chulwalar)
  • Monthly Inflation rate in Chulwalar
  • Proposed spending for National Holidays
  • Influence of National Holiday

The indicators will be converted into individual vectors and subsequently converted into time series. The correlation of the indicators will then be tested against the As Is exports for Chulwalar.

Monthly Change in Export Price Index (CEPI)

CEPIVector <- c(ImportedIndicators[2:13,2],ImportedIndicators[2:13,3],ImportedIndicators[2:13,4],ImportedIndicators[2:13,5],ImportedIndicators[2:13,6],ImportedIndicators[2:13,7])
CEPI <- ts(CEPIVector , start=c(2008,1), end=c(2013,12), frequency=12)
plot(CEPI, main="CEPI")

cor(TotalAsIs, CEPI)
## [1] 0.663925
cor(EfakAsIs , CEPI)
## [1] 0.9303543
cor(WugeAsIs, CEPI)
## [1] 0.7618551
cor(TotalEtelAsIs, CEPI)
## [1] 0.339713
cor(BlueEtelAsIs , CEPI)
## [1] 0.1448837
cor(RedEtelAsIs , CEPI)
## [1] 0.3587646

Monthly Satisfaction Index (SI) government based data

SIGovVector <- c(ImportedIndicators[16:27,2],ImportedIndicators[16:27,3],ImportedIndicators[16:27,4],ImportedIndicators[16:27,5],ImportedIndicators[16:27,6],ImportedIndicators[16:27,7])
SIGov <- ts(SIGovVector , start=c(2008,1), end=c(2013,12), frequency=12)
plot(SIGov, main="SIGov")

cor(TotalAsIs, SIGov)
## [1] 0.2007768
cor(EfakAsIs , SIGov)
## [1] 0.37934
cor(WugeAsIs, SIGov)
## [1] 0.3030266
cor(TotalEtelAsIs, SIGov)
## [1] 0.002556094
cor(BlueEtelAsIs , SIGov)
## [1] -0.04146932
cor(RedEtelAsIs , SIGov)
## [1] 0.009978415

Average monthly temperatures in Chulwalar

TemperatureVector <- c(ImportedIndicators[30:41,2],ImportedIndicators[30:41,3],ImportedIndicators[30:41,4],ImportedIndicators[30:41,5],ImportedIndicators[30:41,6],ImportedIndicators[30:41,7])
Temperature <- ts(TemperatureVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(Temperature, main="Temperature")

cor(TotalAsIs, Temperature)
## [1] -0.3429684
cor(EfakAsIs , Temperature)
## [1] -0.07951179
cor(WugeAsIs, Temperature)
## [1] -0.2045082
cor(TotalEtelAsIs, Temperature)
## [1] -0.453138
cor(BlueEtelAsIs , Temperature)
## [1] -0.6356067
cor(RedEtelAsIs , Temperature)
## [1] -0.4028941

Monthly births in Chulwalar

BirthsVector <- c(ImportedIndicators[44:55,2],ImportedIndicators[44:55,3],ImportedIndicators[44:55,4],ImportedIndicators[44:55,5],ImportedIndicators[44:55,6],ImportedIndicators[44:55,7])
Births <- ts(BirthsVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(Births, main="Births")

cor(TotalAsIs, Births)
## [1] -0.1190228
cor(EfakAsIs , Births)
## [1] -0.05802961
cor(WugeAsIs, Births)
## [1] -0.007371339
cor(TotalEtelAsIs, Births)
## [1] -0.1504242
cor(BlueEtelAsIs , Births)
## [1] -0.2812913
cor(RedEtelAsIs , Births)
## [1] -0.1217222

Monthly Satisfaction Index (SI) external index

SIExternVector <- c(ImportedIndicators[58:69,2],ImportedIndicators[58:69,3],ImportedIndicators[58:69,4],ImportedIndicators[58:69,5],ImportedIndicators[58:69,6],ImportedIndicators[58:69,7])
SIExtern <- ts(SIExternVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(SIExtern, main="SIExtern")

cor(TotalAsIs, SIExtern)
## [1] 0.5883122
cor(EfakAsIs , SIExtern)
## [1] 0.8358147
cor(WugeAsIs, SIExtern)
## [1] 0.6786552
cor(TotalEtelAsIs, SIExtern)
## [1] 0.2865672
cor(BlueEtelAsIs , SIExtern)
## [1] 0.1604768
cor(RedEtelAsIs , SIExtern)
## [1] 0.2960946

Yearly exports from Urbano

UrbanoExportsVector <- c(ImportedIndicators[72:83,2],ImportedIndicators[72:83,3],ImportedIndicators[72:83,4],ImportedIndicators[72:83,5],ImportedIndicators[72:83,6],ImportedIndicators[72:83,7])
UrbanoExports <- ts(UrbanoExportsVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(UrbanoExports, main="UrbanoExports")

cor(TotalAsIs, UrbanoExports)
## [1] 0.638178
cor(EfakAsIs , UrbanoExports)
## [1] 0.9163565
cor(WugeAsIs, UrbanoExports)
## [1] 0.7118468
cor(TotalEtelAsIs, UrbanoExports)
## [1] 0.3182532
cor(BlueEtelAsIs , UrbanoExports)
## [1] 0.1655794
cor(RedEtelAsIs , UrbanoExports)
## [1] 0.3309962

Yearly number of Globalisation Party members in Chulwalar

GlobalisationPartyMembersVector <- c(ImportedIndicators[86:97,2],ImportedIndicators[86:97,3],ImportedIndicators[86:97,4],ImportedIndicators[86:97,5],ImportedIndicators[86:97,6],ImportedIndicators[86:97,7])
GlobalisationPartyMembers <- ts(GlobalisationPartyMembersVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(GlobalisationPartyMembers, main="GlobalisationPartyMembers")

cor(TotalAsIs, GlobalisationPartyMembers)
## [1] 0.630084
cor(EfakAsIs , GlobalisationPartyMembers)
## [1] 0.8963942
cor(WugeAsIs, GlobalisationPartyMembers)
## [1] 0.7193864
cor(TotalEtelAsIs, GlobalisationPartyMembers)
## [1] 0.2994635
cor(BlueEtelAsIs , GlobalisationPartyMembers)
## [1] 0.08547266
cor(RedEtelAsIs , GlobalisationPartyMembers)
## [1] 0.3234832

Monthly Average Export Price Index for Chulwalar

AEPIVector <- c(ImportedIndicators[100:111,2],ImportedIndicators[100:111,3],ImportedIndicators[100:111,4],ImportedIndicators[100:111,5],ImportedIndicators[100:111,6],ImportedIndicators[100:111,7])
AEPI <- ts(AEPIVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(AEPI, main="AEPI")

cor(TotalAsIs, AEPI)
## [1] 0.625232
cor(EfakAsIs , AEPI)
## [1] 0.9056624
cor(WugeAsIs, AEPI)
## [1] 0.7159733
cor(TotalEtelAsIs, AEPI)
## [1] 0.3035506
cor(BlueEtelAsIs , AEPI)
## [1] 0.1577964
cor(RedEtelAsIs , AEPI)
## [1] 0.3157277

Monthly Producer Price Index (PPI) for Etel in Chulwalar

PPIEtelVector <- c(ImportedIndicators[114:125,2],ImportedIndicators[114:125,3],ImportedIndicators[114:125,4],ImportedIndicators[114:125,5],ImportedIndicators[114:125,6],ImportedIndicators[114:125,7])
PPIEtel <- ts(PPIEtelVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(PPIEtel, main="PPIEtel")

cor(TotalAsIs, PPIEtel)
## [1] 0.4836129
cor(EfakAsIs , PPIEtel)
## [1] 0.5865375
cor(WugeAsIs, PPIEtel)
## [1] 0.4920865
cor(TotalEtelAsIs, PPIEtel)
## [1] 0.3374707
cor(BlueEtelAsIs , PPIEtel)
## [1] 0.2445472
cor(RedEtelAsIs , PPIEtel)
## [1] 0.3391872

National Holidays

NationalHolidaysVector <- c(ImportedIndicators[170:181,2],ImportedIndicators[170:181,3],ImportedIndicators[170:181,4],ImportedIndicators[170:181,5],ImportedIndicators[170:181,6],ImportedIndicators[170:181,7])
NationalHolidays <- ts(NationalHolidaysVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(NationalHolidays, main="NationalHolidays")

cor(TotalAsIs, NationalHolidays)
## [1] -0.007883708
cor(EfakAsIs , NationalHolidays)
## [1] 0.001235706
cor(WugeAsIs, NationalHolidays)
## [1] 0.06505569
cor(TotalEtelAsIs, NationalHolidays)
## [1] -0.01081446
cor(BlueEtelAsIs , NationalHolidays)
## [1] 0.02903763
cor(RedEtelAsIs , NationalHolidays)
## [1] -0.01717636

Chulwalar Index (Total value of all companies in Chulwalar)

ChulwalarIndexVector <- c(ImportedIndicators[128:139,2],ImportedIndicators[128:139,3],ImportedIndicators[128:139,4],ImportedIndicators[128:139,5],ImportedIndicators[128:139,6],ImportedIndicators[128:139,7])
ChulwalarIndex <- ts(ChulwalarIndexVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(ChulwalarIndex, main="ChulwalarIndex")

cor(TotalAsIs, ChulwalarIndex)
## [1] 0.4837017
cor(EfakAsIs , ChulwalarIndex)
## [1] 0.7129557
cor(WugeAsIs, ChulwalarIndex)
## [1] 0.5721568
cor(TotalEtelAsIs, ChulwalarIndex)
## [1] 0.2209171
cor(BlueEtelAsIs , ChulwalarIndex)
## [1] 0.1469233
cor(RedEtelAsIs , ChulwalarIndex)
## [1] 0.2242922

Monthly Inflation rate in Chulwalar

InflationVector <- c(ImportedIndicators[142:153,2],ImportedIndicators[142:153,3],ImportedIndicators[142:153,4],ImportedIndicators[142:153,5],ImportedIndicators[142:153,6],ImportedIndicators[142:153,7])
Inflation <- ts(InflationVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(Inflation, main="Inflation")

cor(TotalAsIs, Inflation)
## [1] 0.002438708
cor(EfakAsIs , Inflation)
## [1] 0.1454134
cor(WugeAsIs, Inflation)
## [1] 0.03191332
cor(TotalEtelAsIs, Inflation)
## [1] -0.08378282
cor(BlueEtelAsIs , Inflation)
## [1] 0.02117817
cor(RedEtelAsIs , Inflation)
## [1] -0.0982151

Proposed spending for Independence day presents

IndependenceDayPresentsVector <- c(ImportedIndicators[156:167,2],ImportedIndicators[156:167,3],ImportedIndicators[156:167,4],ImportedIndicators[156:167,5],ImportedIndicators[156:167,6],ImportedIndicators[156:167,7])
IndependenceDayPresents <- ts(IndependenceDayPresentsVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(IndependenceDayPresents, main="IndependenceDayPresents")

cor(TotalAsIs, IndependenceDayPresents)
## [1] 0.4359522
cor(EfakAsIs , IndependenceDayPresents)
## [1] 0.5243145
cor(WugeAsIs, IndependenceDayPresents)
## [1] 0.4892437
cor(TotalEtelAsIs, IndependenceDayPresents)
## [1] 0.2872013
cor(BlueEtelAsIs , IndependenceDayPresents)
## [1] 0.2110373
cor(RedEtelAsIs , IndependenceDayPresents)
## [1] 0.2881631

Influence of National Holidays :

This indicator is an experiment where the influence of National Holidays is extended into the months leading up to the holiday. However later tests show that this indicator is no better for forecasting than the orignial National Holidays indicator.

InfluenceNationalHolidaysVector <- c(ImportedIndicators[184:195,2],ImportedIndicators[184:195,3],ImportedIndicators[184:195,4],ImportedIndicators[184:195,5],ImportedIndicators[184:195,6],ImportedIndicators[184:195,7])
InfluenceNationalHolidays <- ts(InfluenceNationalHolidaysVector, start=c(2008,1), end=c(2013,12), frequency=12)
plot(InfluenceNationalHolidays, main="InfluenceNationalHolidays")

cor(TotalAsIs, InfluenceNationalHolidays)
## [1] 0.3717463
cor(EfakAsIs , InfluenceNationalHolidays)
## [1] 0.09926836
cor(WugeAsIs, InfluenceNationalHolidays)
## [1] 0.3712288
cor(TotalEtelAsIs, InfluenceNationalHolidays)
## [1] 0.4535836
cor(BlueEtelAsIs , InfluenceNationalHolidays)
## [1] 0.2792198
cor(RedEtelAsIs , InfluenceNationalHolidays)
## [1] 0.4643512

Check that the data import has worked

str(CEPIVector)
##  num [1:72] 97.4 97.8 98.3 98.1 98.7 98.9 99.5 99.2 99.1 98.9 ...
str(SIGovVector)  
##  num [1:72] -0.4 -2.9 -2.7 1.7 -1.7 -2.6 -7.1 -11.1 -9.4 -13.5 ...
str(TemperatureVector) 
##  num [1:72] 3.6 3.7 4.2 7.6 14.5 16.9 18 17.4 12.4 9.1 ...
str(BirthsVector)
##  num [1:72] 58519 53370 52852 55048 57398 ...
str(SIExternVector)
##  num [1:72] 4.5 4.5 4.6 4.6 5 4.3 3.4 1.8 1.5 1.7 ...
str(UrbanoExportsVector) 
##  num [1:72] 5850000 5850000 5850000 5850000 5850000 5850000 5850000 5850000 5850000 5850000 ...
str(GlobalisationPartyMembersVector)
##  num [1:72] 45089 45089 45089 45089 45089 ...
str(AEPIVector) 
##  num [1:72] 99 99.3 99.5 99.2 99.5 ...
str(PPIEtelVector) 
##  num [1:72] 100.6 99.7 99.9 99.6 100 ...
str(NationalHolidaysVector) 
##  num [1:72] 0 0 1 0 0 0 0 0 0 0 ...
str(ChulwalarIndexVector)
##  num [1:72] 6852 6748 6535 6949 7097 ...
str(InflationVector) 
##  num [1:72] 2.85 2.84 3.15 2.4 3.03 3.24 3.32 3.12 2.8 2.38 ...
str(IndependenceDayPresentsVector)
##  num [1:72] 221 221 221 221 221 221 221 221 221 221 ...